#ifndef  SHOW_INC
#define  SHOW_INC

#include	"World.h"
#include	"Configure.h"
#include	<iostream>
#include	<stdlib.h>

class Show
{
	public:
		Show( World *wm )
		{
			this->wm = wm;
		}
	public:
		virtual void ShowResult( int cycle ) = 0;

	protected:
		World *wm;
};

class ShowInFile : public Show
{
	public:
		ShowInFile( World *wm ) : Show( wm ) 
		{
			if( (output = fopen( "LifeResult.log", "w" ) ) == NULL )
			{
				std::cout<< "Error! Can't open log file\n";
				exit(-1);
			}
		}

		~ShowInFile()
		{
			fclose( output );
		}

	private:
		FILE *output;

	public:
		void ShowResult( int cycle );
};

class ShowInterface : public Show
{
	public:
		ShowInterface( World *wm ) : Show( wm ) {}
	private:
		ShowInFile *showInFile;

	public:
		void ShowResult( int cycle )
		{
			if( showInFile == NULL )
			{
				showInFile = new ShowInFile( wm );
			}

			showInFile->ShowResult( cycle );
		}
};

#endif   /* ----- #ifndef SHOW_INC  ----- */
